/* ========================================
   移动端响应式优化样式
   ======================================== */

/* 移动端基础优化 */
@media (max-width: 768px) {
    body {
        font-size: 14px;
    }
    
    /* 隐藏侧边栏，改为汉堡菜单 */
    .sidebar {
        position: fixed;
        top: 0;
        left: -300px;
        width: 300px;
        height: 100vh;
        z-index: 1040;
        transition: left 0.3s ease;
        overflow-y: auto;
        padding: 20px 0;
    }
    
    .sidebar.show {
        left: 0;
    }
    
    /* 移动端菜单列表样式 - 完全展开 */
    .sidebar .mobile-nav-list {
        display: flex !important;
        flex-direction: column;
        width: 100%;
        padding: 0;
        margin: 0;
    }
    
    .sidebar .navbar-brand {
        padding: 15px 20px;
        margin-bottom: 10px;
        border-bottom: 1px solid rgba(255,255,255,0.1);
    }
    
    .sidebar .nav-item {
        width: 100%;
        margin: 0;
    }
    
    .sidebar .nav-link {
        display: flex;
        align-items: center;
        padding: 15px 20px !important;
        margin: 0 !important;
        border-radius: 0 !important;
        font-size: 16px;
        border-left: 4px solid transparent;
        transition: all 0.2s;
    }
    
    .sidebar .nav-link i {
        font-size: 20px;
        width: 30px;
        margin-right: 15px;
    }
    
    .sidebar .nav-link:hover {
        background: rgba(255,255,255,0.1) !important;
        border-left-color: white;
    }
    
    .sidebar .nav-link.active {
        background: rgba(255,255,255,0.2) !important;
        border-left-color: white;
        font-weight: 600;
    }
    
    /* 隐藏桌面端的用户下拉菜单 */
    .sidebar .d-flex.align-items-center {
        display: none !important;
    }
    
    /* 显示移动端退出登录选项 */
    .sidebar .mobile-only {
        display: block !important;
    }
    
    .main-content {
        margin-left: 0 !important;
        padding: 10px;
    }
    
    /* 移动端顶部导航栏 */
    .mobile-header {
        display: flex !important;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 56px;
        background: var(--primary-color);
        color: white;
        z-index: 1030;
        align-items: center;
        padding: 0 15px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
    
    .mobile-menu-btn {
        background: none;
        border: none;
        color: white;
        font-size: 24px;
        padding: 8px;
        cursor: pointer;
    }
    
    .mobile-title {
        flex: 1;
        text-align: center;
        font-size: 18px;
        font-weight: 600;
    }
    
    .mobile-user {
        font-size: 14px;
    }
    
    /* 遮罩层 */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1035;
    }
    
    .sidebar-overlay.show {
        display: block;
    }
    
    /* 主内容区域上移 */
    .container-fluid {
        padding-top: 66px !important;
    }
    
    /* 卡片优化 */
    .card {
        margin-bottom: 15px;
        border-radius: 12px;
    }
    
    .card-body {
        padding: 15px;
    }
    
    /* 按钮组优化 */
    .btn-group-mobile {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .btn-group-mobile .btn {
        flex: 1 1 calc(50% - 4px);
        min-width: 0;
        font-size: 13px;
        padding: 8px 12px;
    }
    
    /* 账号管理操作按钮组优化 */
    .account-action-buttons {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        justify-content: flex-end;
    }
    
    .account-action-buttons .action-btn {
        flex: 1 1 calc(50% - 4px);
        min-width: 0;
        max-width: calc(50% - 4px);
        font-size: 13px;
        padding: 10px 12px;
        white-space: nowrap;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .account-action-buttons .action-btn i {
        font-size: 14px;
    }
    
    /* 页面顶部空白优化 - 统一样式 */
    .settings-page,
    .roles-page,
    .tasks-page,
    .statistics-page {
        padding-top: 10px !important;
        margin-top: 0 !important;
    }
    
    .settings-page .page-title,
    .roles-page .page-title,
    .tasks-page .page-title,
    .statistics-page .page-title {
        font-size: 20px;
        margin-bottom: 15px !important;
        padding-bottom: 10px;
        border-bottom: 2px solid var(--border-color);
    }
    
    /* 移动端行标题间距优化 */
    .roles-page .row.mb-4,
    .tasks-page .row.mb-4,
    .statistics-page .row.mb-4 {
        margin-bottom: 1rem !important;
    }
    
    /* 系统配置Tab垂直排列 */
    .settings-tabs {
        display: flex !important;
        flex-direction: column !important;
        border-bottom: none !important;
        margin-bottom: 15px !important;
        background: var(--bg-card);
        border-radius: 8px;
        overflow: hidden;
    }
    
    .settings-tabs .nav-item {
        width: 100%;
        margin: 0 !important;
    }
    
    .settings-tabs .nav-link {
        width: 100%;
        text-align: left !important;
        padding: 12px 15px !important;
        border: none !important;
        border-bottom: 1px solid var(--border-color) !important;
        border-radius: 0 !important;
        background: transparent;
        color: var(--text-primary) !important;
        font-size: 14px;
        display: flex;
        align-items: center;
        transition: all 0.2s;
    }
    
    .settings-tabs .nav-item:last-child .nav-link {
        border-bottom: none !important;
    }
    
    .settings-tabs .nav-link:hover {
        background: var(--bg-secondary) !important;
    }
    
    .settings-tabs .nav-link.active {
        background: var(--primary-color) !important;
        color: white !important;
        font-weight: 600;
        border-left: 4px solid var(--primary-hover) !important;
    }
    
    /* 移动端表格和卡片显示策略 */
    /* 默认：表格可以横向滚动 */
    .table-responsive {
        display: block !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* 移动端卡片视图默认显示 */
    .table-mobile-cards {
        display: block !important;
    }
    
    /* 表格基础样式优化 */
    .table-responsive .table {
        min-width: 600px;
        font-size: 13px;
    }
    
    .table-responsive .table th,
    .table-responsive .table td {
        padding: 8px;
        white-space: nowrap;
    }
    
    /* 操作按钮优化 */
    .table-responsive .btn-sm {
        padding: 4px 8px;
        font-size: 12px;
    }
    
    .mobile-card-item {
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        border-radius: 10px;
        padding: 12px;
        margin-bottom: 10px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    }
    
    .mobile-card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 10px;
        padding-bottom: 8px;
        border-bottom: 1px solid var(--border-color);
    }
    
    .mobile-card-title {
        font-weight: 600;
        font-size: 15px;
        color: var(--text-primary);
    }
    
    .mobile-card-body {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        margin-bottom: 10px;
    }
    
    .mobile-card-field {
        font-size: 13px;
    }
    
    .mobile-card-label {
        color: var(--text-secondary);
        font-size: 12px;
        margin-bottom: 2px;
    }
    
    .mobile-card-value {
        color: var(--text-primary);
        font-weight: 500;
    }
    
    .mobile-card-actions {
        display: flex;
        gap: 6px;
        flex-wrap: wrap;
    }
    
    .mobile-card-actions .btn {
        flex: 1;
        font-size: 12px;
        padding: 6px 10px;
    }
    
    /* 模态框优化 */
    .modal-dialog {
        margin: 10px;
        max-width: calc(100% - 20px);
    }
    
    .modal-body {
        padding: 15px;
    }
    
    .modal-footer {
        padding: 10px 15px;
    }
    
    .modal-footer .btn {
        padding: 8px 16px;
        font-size: 14px;
    }
    
    /* 表单优化 */
    .form-label {
        font-size: 13px;
        margin-bottom: 4px;
    }
    
    .form-control,
    .form-select {
        font-size: 14px;
        padding: 8px 12px;
    }
    
    .row.mb-3 {
        margin-bottom: 12px !important;
    }
    
    /* 统计卡片优化 */
    .stat-card {
        padding: 12px;
        border-radius: 10px;
        margin-bottom: 10px;
    }
    
    .stat-card h3 {
        font-size: 24px;
        margin-bottom: 4px;
    }
    
    .stat-card small {
        font-size: 12px;
    }
    
    /* 搜索筛选区域优化 */
    .search-filters {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }
    
    .search-filters .form-control,
    .search-filters .form-select {
        width: 100%;
    }
    
    /* 图表容器 */
    .chart-container {
        position: relative;
        height: 250px;
        margin-bottom: 20px;
    }
    
    /* 日期选择器优化 */
    .date-navigation {
        display: flex;
        gap: 5px;
    }
    
    .date-navigation .btn {
        padding: 8px;
        font-size: 14px;
    }
    
    .date-navigation input[type="date"] {
        flex: 1;
        font-size: 14px;
    }
    
    /* 底部导航栏（可选） */
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bg-card);
        border-top: 1px solid var(--border-color);
        box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
        z-index: 1020;
        display: none; /* 默认不显示，可根据需要启用 */
    }
    
    .bottom-nav-item {
        flex: 1;
        text-align: center;
        padding: 8px;
        color: var(--text-secondary);
        text-decoration: none;
        font-size: 12px;
    }
    
    .bottom-nav-item.active {
        color: var(--primary-color);
    }
    
    .bottom-nav-item i {
        display: block;
        font-size: 20px;
        margin-bottom: 2px;
    }
    
    /* 徽章优化 */
    .badge {
        font-size: 11px;
        padding: 4px 8px;
    }
    
    /* 页面标题优化 */
    h4.mb-4 {
        font-size: 18px;
        margin-bottom: 15px !important;
        display: none; /* 移动端隐藏，因为顶部导航已显示标题 */
    }
    
    /* Checkbox优化 */
    .form-check-input {
        width: 20px;
        height: 20px;
    }
    
    /* 下拉菜单优化 */
    .dropdown-menu {
        font-size: 14px;
    }
    
    .dropdown-item {
        padding: 10px 15px;
    }
    
    /* Toast通知优化 */
    .toast {
        font-size: 14px;
    }
    
    /* 分页优化 */
    .pagination {
        font-size: 14px;
    }
    
    .page-link {
        padding: 6px 12px;
    }
}

/* 平板设备优化 (768px - 992px) */
@media (min-width: 768px) and (max-width: 992px) {
    .sidebar {
        width: 220px;
    }
    
    .main-content {
        margin-left: 220px;
    }
    
    .mobile-card-body {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* 超小屏幕优化 (< 576px) */
@media (max-width: 576px) {
    .container-fluid {
        padding-left: 10px;
        padding-right: 10px;
    }
    
    .btn-group-mobile .btn {
        flex: 1 1 100%;
    }
    
    .stat-card h3 {
        font-size: 20px;
    }
    
    .mobile-card-body {
        grid-template-columns: 1fr;
    }
    
    /* 超小屏幕按钮垂直排列 */
    .account-action-buttons .action-btn {
        flex: 1 1 100%;
        max-width: 100%;
    }
}

/* 桌面端显示表格 */
@media (min-width: 769px) {
    .mobile-header {
        display: none !important;
    }
    
    .table-mobile-cards {
        display: none !important;
    }
    
    .table-responsive {
        display: block !important;
    }
    
    /* 桌面端隐藏移动端专属元素 */
    .mobile-only {
        display: none !important;
    }
    
    /* 桌面端显示用户下拉菜单 */
    .sidebar .d-flex.align-items-center {
        display: flex !important;
    }
    
    /* 桌面端按钮组正常显示 */
    .account-action-buttons {
        display: inline-flex;
        flex-wrap: nowrap;
        gap: 8px;
    }
    
    .account-action-buttons .action-btn {
        flex: 0 0 auto;
        max-width: none;
        white-space: nowrap;
    }
    
    /* 桌面端页面正常显示 */
    .settings-page,
    .roles-page,
    .tasks-page,
    .statistics-page {
        padding-top: 2rem !important;
        margin-top: 0;
    }
    
    .settings-page .page-title,
    .roles-page .page-title,
    .tasks-page .page-title,
    .statistics-page .page-title {
        font-size: 2rem;
        margin-bottom: 1.5rem !important;
        border-bottom: none;
    }
    
    /* 桌面端行间距正常 */
    .roles-page .row.mb-4,
    .tasks-page .row.mb-4,
    .statistics-page .row.mb-4 {
        margin-bottom: 1.5rem !important;
    }
    
    .settings-tabs {
        display: flex !important;
        flex-direction: row !important;
        border-bottom: 1px solid var(--border-color) !important;
        background: transparent;
        border-radius: 0;
    }
    
    .settings-tabs .nav-item {
        width: auto;
    }
    
    .settings-tabs .nav-link {
        width: auto;
        text-align: center !important;
        padding: 0.5rem 1rem !important;
        border: 1px solid transparent !important;
        border-radius: 0.25rem 0.25rem 0 0 !important;
        font-size: 1rem;
        border-left: none !important;
    }
    
    .settings-tabs .nav-link.active {
        border-color: var(--border-color) var(--border-color) transparent !important;
        background: var(--bg-card) !important;
        color: var(--text-primary) !important;
        border-left: none !important;
    }
}

/* 移动端卡片和表格共存策略 */
@media (max-width: 768px) {
    /* 任务页面：优先显示卡片，隐藏表格 */
    body[data-page="tasks"] .card.table-responsive {
        display: none !important;
    }
    
    body[data-page="tasks"] .table-mobile-cards {
        display: block !important;
    }
    
    /* 其他页面：显示表格（横向滚动） */
    body:not([data-page="tasks"]) .table-mobile-cards {
        display: none !important;
    }
    
    body:not([data-page="tasks"]) .table-responsive {
        display: block !important;
    }
}
